// 来自https://www.bilibili.com/video/BV1pb411v7m7?spm_id_from=333.337.search-card.all.click

package main

import (
	"errors"
	"fmt"
)

func e1() {
	var err error

	defer fmt.Println(err)

	err = errors.New("defer 1 err")
	return
}
func e2() {
	var err error

	defer func() {
		fmt.Println(err)
	}()

	err = errors.New("defer 2 err")
	return
}
func e3() {
	var err error

	defer func(err error) {
		fmt.Println(err)
	}(err)

	err = errors.New("defer 3 err")
	return
}

func D4main() {
	e1()
	e2()
	e3()
}
